<!--
 * @FilePath: \crm\application\crm\view\auth\role\add.html
-->

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>角色添加</title>
    <link rel="stylesheet" href="/static/crm/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/crm/css/public.css" media="all">
    <link rel="stylesheet" href="/static/crm/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
</head>

<body>
    <div class="layuimini-container">
        <form id="app-form" class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">权限名称</label>
                <div class="layui-input-block">
                    <input type="text" name="auth_name" class="layui-input" placeholder="请输入权限名称"
                        value="{$row.auth_name|default=''}">
                    <tip>填写权限名称。</tip>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注信息</label>
                <div class="layui-input-block">
                    <textarea name="remark" class="layui-textarea" placeholder="请输入备注信息">{$row.remark|default=''}</textarea>
                </div>
            </div>

            <div class="layui-form-item text-center" style="padding-left: 45%;">
                <button id="formDemo" type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit
                    lay-filter="auth_add">确认</button>
                <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
            </div>
        </form>
    </div>
    <script src="/static/crm/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script>
        layui.use(['layer', 'jquery', 'form'], function () {
            var layer = layui.layer,
                $ = layui.jquery,
                form = layui.form;

            form.on('submit(auth_add)', function (data) {
                $.ajax({
                    type: 'post',
                    url: "/crm/auth.role/{$edit ?? 'add'}/id/{$row.id|default=''}",
                    dataType: 'json',
                    data: data.field,
                    success: function (result) {
                        if (result.code == 1) {
                            layer.msg(result.msg, {
                                time: 800,
                                end: function () {
                                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(iframeIndex);
                                }
                            });
                        } else {
                            layer.msg(result.msg);
                        }
                    }
                })
                return false;
            });
        });
    </script>
</body>

</html>